home *** CD-ROM | disk | FTP | other *** search
- /* MIKE.INI
- The file MIKE.PL always loads this file last, so this is the place
- to add 'customizations'. A few sample customizations are included to
- give you the idea.
- If you want ['mike.pl'] to automatically load any Prolog files of
- your own, we suggest you that you add
- ?- reconsult('<yourfile>').
- here within MIKE.INI
-
- */
-
- /* Customization 1: some extra syntactic sugar for enhancing rule syntax
- with ordinary arithmetic operators. If you want to add more of your
- own in some other file, be sure to use the 'directive' form, e.g.
- ?- allow_prolog_lhs(X < Y).
- ?- allow_prolog_rhs(foo(X,Y)).
- The first directive allows '<' to be used on the left hand side
- (IF-PART) of a MIKE rule.
- The second allows some user-defined predicate 'foo' to be used
- on the right hand side (THEN-PART) of a MIKE rule.
- (These directives are defined in the file ENGINE2.PL)
- */
- /* We want to use a new assignment operator ':=' */
- ?- op(740,xfx,':='). /* So we declare it in Prolog */
-
- Var := Term :- /* Then we define its meaning in Prolog ... */
- Var is Term. /* Simply calls the built-in Prolog 'is' for assignment */
-
- ?- allow_prolog_rhs(X := Y). /* Then we tell MIKE to allow it as a right-hand
- side action */
-
- /* The next four operators are already known to Prolog, so we just need
- to tell MIKE that they should be allowed on the left hand side of rules */
-
- ?- allow_prolog_lhs(X>Y).
- ?- allow_prolog_lhs(X<Y).
- ?- allow_prolog_lhs(X>=Y).
- ?- allow_prolog_lhs(X=<Y).
-
- /*
- with the above declarations, you could now write a rule like this:
-
- rule foo forward
- if
- [annual_earnings, Person, AE] &
- AE > 25000
- then
- MonthlySalary := AE/12 &
- MonthlyTax := MonthlySalary*0.40 &
- announce [Person, ' pays this higher rate montly tax: ', MonthlyTax].
-
- additional comments about these operators are in the file READ.ME
- */
- ?- op(900,fx, ed).
-
- ed FILENAME :-
- edit(FILENAME, 180000).
- /* second argument to 'edit' reserves that many bytes disk swapping space */
-
- ?- reconsult('extras.pl'). /* TTY multiple-choice menus & 'forall' */
- /* Uncomment the next line if you want to experiment with a
- 'hypothetical worlds' mechanism, as illustrated in the files
- RNWORLD.PL and STRWORLD.PL
- */
- /* ?- reconsult('worlds.pl'). */